const OSS = require('ali-oss');
const {
  region,
  endpoint,
  accessKeyId,
  accessKeySecret,
  bucket,
  bucketDir,
} = require('./ali-oss-config');

let client = new OSS({
  region,
  endpoint,
  accessKeyId,
  accessKeySecret,
  bucket,
});

async function put(name, file) {
  try {
    let r1 = await client.put(bucketDir + name, file);
    console.log('put success: %j', r1);
  } catch (e) {
    console.error('error: %j', e);
  }
}

module.exports = {
  put,
};
